<?php

namespace app\command;

use Workerman\Worker;
use think\console\Input;
use think\console\Output;
use GatewayWorker\Gateway;
use think\console\Command;

class GatewayWork extends Command
{
    protected function configure()
    {
        $this->setName('gateway')->setDescription('gateway start');
    }

    protected function execute(Input $input, Output $output)
    {
        // 指令输出
        $gateway = new Gateway("websocket://0.0.0.0:" . config('extra.socket.websocket_port'));
        $gateway->name = 'gateway';
        $gateway->count = 1;
        $gateway->lanIp = '127.0.0.1';
        $gateway->startPort = config('extra.socket.gateway_port');
        $gateway->registerAddress = '127.0.0.1:' . config('extra.socket.register_port');
        $gateway->pingInterval = 55;
        $gateway->pingData = '{"type":"ping"}';
        Worker::runAll();
    }
}
